.class public Llt/noframe/gpsfarmguide/views/ActivitySave;
.super Llt/noframe/gpsfarmguide/views/BaseActivity;
.source "ActivitySave.java"


# instance fields
.field private groups:Ljava/util/List;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/List<",
            "Llt/noframe/gpsfarmguide/models/GroupModel;",
            ">;"
        }
    .end annotation
.end field

.field groupsSpinnerListener:Landroid/widget/AdapterView$OnItemSelectedListener;

.field private measureGroup:Landroid/widget/Spinner;

.field private measureName:Landroid/widget/EditText;

.field private measureUniqueId:Landroid/widget/EditText;

.field private measuringModel:Llt/noframe/gpsfarmguide/models/MeasuringModel;

.field private validator:Llt/noframe/gpsfarmguide/utils/Validator;


# direct methods
.method public constructor <init>()V
    .locals 1

    .line 36
    invoke-direct {p0}, Llt/noframe/gpsfarmguide/views/BaseActivity;-><init>()V

    .line 43
    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

    iput-object v0, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->groups:Ljava/util/List;

    .line 161
    new-instance v0, Llt/noframe/gpsfarmguide/views/ActivitySave$2;

    invoke-direct {v0, p0}, Llt/noframe/gpsfarmguide/views/ActivitySave$2;-><init>(Llt/noframe/gpsfarmguide/views/ActivitySave;)V

    iput-object v0, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->groupsSpinnerListener:Landroid/widget/AdapterView$OnItemSelectedListener;

    return-void
.end method

.method static synthetic access$000(Llt/noframe/gpsfarmguide/views/ActivitySave;)Landroid/widget/Spinner;
    .locals 0

    .line 36
    iget-object p0, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->measureGroup:Landroid/widget/Spinner;

    return-object p0
.end method

.method static synthetic access$100(Llt/noframe/gpsfarmguide/views/ActivitySave;)V
    .locals 0

    .line 36
    invoke-direct {p0}, Llt/noframe/gpsfarmguide/views/ActivitySave;->createNewGroupDialog()V

    return-void
.end method

.method static synthetic access$200(Llt/noframe/gpsfarmguide/views/ActivitySave;)Llt/noframe/gpsfarmguide/utils/Validator;
    .locals 0

    .line 36
    iget-object p0, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->validator:Llt/noframe/gpsfarmguide/utils/Validator;

    return-object p0
.end method

.method static synthetic access$300(Llt/noframe/gpsfarmguide/views/ActivitySave;)V
    .locals 0

    .line 36
    invoke-direct {p0}, Llt/noframe/gpsfarmguide/views/ActivitySave;->createGroupsAdapter()V

    return-void
.end method

.method static synthetic access$400(Llt/noframe/gpsfarmguide/views/ActivitySave;)Ljava/util/List;
    .locals 0

    .line 36
    iget-object p0, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->groups:Ljava/util/List;

    return-object p0
.end method

.method private createGroupsAdapter()V
    .locals 4

    .line 116
    invoke-static {}, Llt/noframe/gpsfarmguide/database/DB;->getDB()Llt/noframe/gpsfarmguide/database/DB;

    move-result-object v0

    invoke-virtual {v0}, Llt/noframe/gpsfarmguide/database/DB;->getGroups()Ljava/util/List;

    move-result-object v0

    iput-object v0, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->groups:Ljava/util/List;

    .line 117
    iget-object v0, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->groups:Ljava/util/List;

    new-instance v1, Llt/noframe/gpsfarmguide/models/GroupModel;

    const v2, 0x7f110188

    invoke-virtual {p0, v2}, Landroid/app/Activity;->getString(I)Ljava/lang/String;

    move-result-object v2

    const/4 v3, -0x1

    invoke-direct {v1, v3, v2}, Llt/noframe/gpsfarmguide/models/GroupModel;-><init>(ILjava/lang/String;)V

    invoke-interface {v0, v1}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 118
    new-instance v0, Landroid/widget/ArrayAdapter;

    iget-object v1, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->groups:Ljava/util/List;

    const v2, 0x1090008

    invoke-direct {v0, p0, v2, v1}, Landroid/widget/ArrayAdapter;-><init>(Landroid/content/Context;ILjava/util/List;)V

    const v1, 0x1090009

    .line 120
    invoke-virtual {v0, v1}, Landroid/widget/ArrayAdapter;->setDropDownViewResource(I)V

    .line 121
    iget-object v1, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->measureGroup:Landroid/widget/Spinner;

    invoke-virtual {v1, v0}, Landroid/widget/Spinner;->setAdapter(Landroid/widget/SpinnerAdapter;)V

    return-void
.end method

.method private createNewGroupDialog()V
    .locals 4

    .line 182
    new-instance v0, Landroid/widget/EditText;

    invoke-direct {v0, p0}, Landroid/widget/EditText;-><init>(Landroid/content/Context;)V

    .line 183
    new-instance v1, Landroid/app/AlertDialog$Builder;

    invoke-direct {v1, p0}, Landroid/app/AlertDialog$Builder;-><init>(Landroid/content/Context;)V

    const v2, 0x7f11009c

    .line 184
    invoke-virtual {p0, v2}, Landroid/app/Activity;->getString(I)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Landroid/app/AlertDialog$Builder;->setTitle(Ljava/lang/CharSequence;)Landroid/app/AlertDialog$Builder;

    move-result-object v1

    const v2, 0x7f1100c5

    .line 185
    invoke-virtual {p0, v2}, Landroid/app/Activity;->getString(I)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Landroid/app/AlertDialog$Builder;->setMessage(Ljava/lang/CharSequence;)Landroid/app/AlertDialog$Builder;

    move-result-object v1

    const/4 v2, 0x0

    .line 186
    invoke-virtual {v1, v2}, Landroid/app/AlertDialog$Builder;->setCancelable(Z)Landroid/app/AlertDialog$Builder;

    move-result-object v1

    .line 187
    invoke-virtual {v1, v0}, Landroid/app/AlertDialog$Builder;->setView(Landroid/view/View;)Landroid/app/AlertDialog$Builder;

    move-result-object v1

    const v2, 0x7f110174

    .line 188
    invoke-virtual {p0, v2}, Landroid/app/Activity;->getString(I)Ljava/lang/String;

    move-result-object v2

    const/4 v3, 0x0

    invoke-virtual {v1, v2, v3}, Landroid/app/AlertDialog$Builder;->setPositiveButton(Ljava/lang/CharSequence;Landroid/content/DialogInterface$OnClickListener;)Landroid/app/AlertDialog$Builder;

    move-result-object v1

    const v2, 0x7f11004f

    .line 189
    invoke-virtual {p0, v2}, Landroid/app/Activity;->getString(I)Ljava/lang/String;

    move-result-object v2

    new-instance v3, Llt/noframe/gpsfarmguide/views/ActivitySave$3;

    invoke-direct {v3, p0}, Llt/noframe/gpsfarmguide/views/ActivitySave$3;-><init>(Llt/noframe/gpsfarmguide/views/ActivitySave;)V

    invoke-virtual {v1, v2, v3}, Landroid/app/AlertDialog$Builder;->setNegativeButton(Ljava/lang/CharSequence;Landroid/content/DialogInterface$OnClickListener;)Landroid/app/AlertDialog$Builder;

    move-result-object v1

    .line 195
    invoke-virtual {v1}, Landroid/app/AlertDialog$Builder;->create()Landroid/app/AlertDialog;

    move-result-object v1

    .line 198
    new-instance v2, Llt/noframe/gpsfarmguide/views/ActivitySave$4;

    invoke-direct {v2, p0, v1, v0}, Llt/noframe/gpsfarmguide/views/ActivitySave$4;-><init>(Llt/noframe/gpsfarmguide/views/ActivitySave;Landroid/app/AlertDialog;Landroid/widget/EditText;)V

    invoke-virtual {v1, v2}, Landroid/app/AlertDialog;->setOnShowListener(Landroid/content/DialogInterface$OnShowListener;)V

    .line 226
    invoke-virtual {v1}, Landroid/app/AlertDialog;->show()V

    return-void
.end method

.method private fillInfo()V
    .locals 4

    .line 135
    iget-object v0, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->measureName:Landroid/widget/EditText;

    iget-object v1, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->measuringModel:Llt/noframe/gpsfarmguide/models/MeasuringModel;

    invoke-virtual {v1}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->getName()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Landroid/widget/EditText;->setText(Ljava/lang/CharSequence;)V

    .line 136
    iget-object v0, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->measureUniqueId:Landroid/widget/EditText;

    iget-object v1, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->measuringModel:Llt/noframe/gpsfarmguide/models/MeasuringModel;

    invoke-virtual {v1}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->getUniqueId()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Landroid/widget/EditText;->setText(Ljava/lang/CharSequence;)V

    const/4 v0, 0x0

    const/4 v1, 0x0

    .line 139
    :goto_0
    iget-object v2, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->groups:Ljava/util/List;

    invoke-interface {v2}, Ljava/util/List;->size()I

    move-result v2

    if-ge v1, v2, :cond_1

    .line 140
    iget-object v2, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->groups:Ljava/util/List;

    invoke-interface {v2, v1}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Llt/noframe/gpsfarmguide/models/GroupModel;

    invoke-virtual {v2}, Llt/noframe/gpsfarmguide/models/GroupModel;->getId()I

    move-result v2

    iget-object v3, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->measuringModel:Llt/noframe/gpsfarmguide/models/MeasuringModel;

    invoke-virtual {v3}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->getGroup()I

    move-result v3

    if-ne v2, v3, :cond_0

    move v0, v1

    goto :goto_1

    :cond_0
    add-int/lit8 v1, v1, 0x1

    goto :goto_0

    .line 145
    :cond_1
    :goto_1
    iget-object v1, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->measureGroup:Landroid/widget/Spinner;

    invoke-virtual {v1, v0}, Landroid/widget/Spinner;->setSelection(I)V

    return-void
.end method

.method private ini()V
    .locals 2

    .line 103
    new-instance v0, Llt/noframe/gpsfarmguide/utils/Validator;

    invoke-direct {v0, p0}, Llt/noframe/gpsfarmguide/utils/Validator;-><init>(Landroid/content/Context;)V

    iput-object v0, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->validator:Llt/noframe/gpsfarmguide/utils/Validator;

    const v0, 0x7f090173

    .line 105
    invoke-virtual {p0, v0}, Landroidx/appcompat/app/AppCompatActivity;->findViewById(I)Landroid/view/View;

    move-result-object v0

    check-cast v0, Landroid/widget/EditText;

    iput-object v0, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->measureName:Landroid/widget/EditText;

    const v0, 0x7f090170

    .line 106
    invoke-virtual {p0, v0}, Landroidx/appcompat/app/AppCompatActivity;->findViewById(I)Landroid/view/View;

    move-result-object v0

    check-cast v0, Landroid/widget/Spinner;

    iput-object v0, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->measureGroup:Landroid/widget/Spinner;

    .line 107
    iget-object v0, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->measureGroup:Landroid/widget/Spinner;

    iget-object v1, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->groupsSpinnerListener:Landroid/widget/AdapterView$OnItemSelectedListener;

    invoke-virtual {v0, v1}, Landroid/widget/Spinner;->setOnItemSelectedListener(Landroid/widget/AdapterView$OnItemSelectedListener;)V

    const v0, 0x7f090172

    .line 108
    invoke-virtual {p0, v0}, Landroidx/appcompat/app/AppCompatActivity;->findViewById(I)Landroid/view/View;

    move-result-object v0

    check-cast v0, Landroid/widget/EditText;

    iput-object v0, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->measureUniqueId:Landroid/widget/EditText;

    .line 109
    invoke-direct {p0}, Llt/noframe/gpsfarmguide/views/ActivitySave;->createGroupsAdapter()V

    return-void
.end method

.method private isInputsValid()Z
    .locals 2

    .line 129
    iget-object v0, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->validator:Llt/noframe/gpsfarmguide/utils/Validator;

    iget-object v1, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->measureName:Landroid/widget/EditText;

    invoke-virtual {v0, v1}, Llt/noframe/gpsfarmguide/utils/Validator;->isEmpty(Landroid/widget/EditText;)Z

    move-result v0

    if-eqz v0, :cond_0

    const/4 v0, 0x0

    return v0

    :cond_0
    const/4 v0, 0x1

    return v0
.end method

.method private saveMeasure()V
    .locals 2

    .line 152
    iget-object v0, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->measuringModel:Llt/noframe/gpsfarmguide/models/MeasuringModel;

    iget-object v1, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->measureName:Landroid/widget/EditText;

    invoke-static {v1}, Llt/noframe/gpsfarmguide/utils/Utils;->getString(Landroid/widget/EditText;)Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/String;->trim()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->setName(Ljava/lang/String;)V

    .line 153
    iget-object v0, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->measuringModel:Llt/noframe/gpsfarmguide/models/MeasuringModel;

    iget-object v1, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->measureGroup:Landroid/widget/Spinner;

    invoke-virtual {v1}, Landroid/widget/Spinner;->getSelectedItem()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Llt/noframe/gpsfarmguide/models/GroupModel;

    invoke-virtual {v1}, Llt/noframe/gpsfarmguide/models/GroupModel;->getId()I

    move-result v1

    invoke-virtual {v0, v1}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->setGroup(I)V

    .line 154
    iget-object v0, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->measuringModel:Llt/noframe/gpsfarmguide/models/MeasuringModel;

    iget-object v1, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->measureUniqueId:Landroid/widget/EditText;

    invoke-static {v1}, Llt/noframe/gpsfarmguide/utils/Utils;->getString(Landroid/widget/EditText;)Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/String;->trim()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->setUniqueId(Ljava/lang/String;)V

    .line 155
    invoke-static {}, Llt/noframe/gpsfarmguide/database/DB;->getDB()Llt/noframe/gpsfarmguide/database/DB;

    move-result-object v0

    iget-object v1, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->measuringModel:Llt/noframe/gpsfarmguide/models/MeasuringModel;

    invoke-virtual {v0, v1}, Llt/noframe/gpsfarmguide/database/DB;->saveMeasure(Llt/noframe/gpsfarmguide/models/MeasuringModel;)V

    .line 156
    new-instance v0, Landroid/content/Intent;

    invoke-direct {v0}, Landroid/content/Intent;-><init>()V

    const/4 v1, -0x1

    .line 157
    invoke-virtual {p0, v1, v0}, Landroid/app/Activity;->setResult(ILandroid/content/Intent;)V

    .line 158
    invoke-virtual {p0}, Landroid/app/Activity;->finish()V

    return-void
.end method


# virtual methods
.method protected onCreate(Landroid/os/Bundle;)V
    .locals 3

    .line 47
    new-instance v0, Ljava/util/Locale;

    const-string v1, "en"

    const-string v2, "US"

    invoke-direct {v0, v1, v2}, Ljava/util/Locale;-><init>(Ljava/lang/String;Ljava/lang/String;)V

    invoke-static {v0}, Ljava/util/Locale;->setDefault(Ljava/util/Locale;)V

    .line 48
    invoke-super {p0, p1}, Llt/noframe/gpsfarmguide/views/BaseActivity;->onCreate(Landroid/os/Bundle;)V

    const p1, 0x7f0c0022

    .line 49
    invoke-virtual {p0, p1}, Landroidx/appcompat/app/AppCompatActivity;->setContentView(I)V

    .line 50
    invoke-static {p0}, Llt/noframe/gpsfarmguide/App;->setContext(Landroid/content/Context;)V

    .line 51
    invoke-static {}, Llt/noframe/gpsfarmguide/App;->getTracker()Lcom/google/android/gms/analytics/Tracker;

    const p1, 0x7f090262

    .line 53
    invoke-virtual {p0, p1}, Landroidx/appcompat/app/AppCompatActivity;->findViewById(I)Landroid/view/View;

    move-result-object p1

    check-cast p1, Landroidx/appcompat/widget/Toolbar;

    .line 54
    invoke-virtual {p0}, Landroidx/appcompat/app/AppCompatActivity;->getResources()Landroid/content/res/Resources;

    move-result-object v0

    const v1, 0x106000b

    invoke-virtual {v0, v1}, Landroid/content/res/Resources;->getColor(I)I

    move-result v0

    invoke-virtual {p1, v0}, Landroidx/appcompat/widget/Toolbar;->setTitleTextColor(I)V

    .line 55
    invoke-virtual {p0, p1}, Landroidx/appcompat/app/AppCompatActivity;->setSupportActionBar(Landroidx/appcompat/widget/Toolbar;)V

    .line 56
    invoke-virtual {p0}, Landroidx/appcompat/app/AppCompatActivity;->getSupportActionBar()Landroidx/appcompat/app/ActionBar;

    move-result-object p1

    if-eqz p1, :cond_0

    .line 58
    invoke-virtual {p0}, Landroidx/appcompat/app/AppCompatActivity;->getSupportActionBar()Landroidx/appcompat/app/ActionBar;

    move-result-object p1

    const/4 v0, 0x1

    invoke-virtual {p1, v0}, Landroidx/appcompat/app/ActionBar;->setDisplayHomeAsUpEnabled(Z)V

    .line 59
    invoke-virtual {p0}, Landroidx/appcompat/app/AppCompatActivity;->getSupportActionBar()Landroidx/appcompat/app/ActionBar;

    move-result-object p1

    const v0, 0x7f0800ce

    invoke-static {p0, v0}, Landroidx/core/content/ContextCompat;->getDrawable(Landroid/content/Context;I)Landroid/graphics/drawable/Drawable;

    move-result-object v0

    invoke-virtual {p1, v0}, Landroidx/appcompat/app/ActionBar;->setHomeAsUpIndicator(Landroid/graphics/drawable/Drawable;)V

    .line 62
    :cond_0
    invoke-static {}, Llt/noframe/gpsfarmguide/Data;->getInstance()Llt/noframe/gpsfarmguide/Data;

    move-result-object p1

    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/Data;->getCurrent_measuring()Llt/noframe/gpsfarmguide/models/MeasuringModel;

    move-result-object p1

    iput-object p1, p0, Llt/noframe/gpsfarmguide/views/ActivitySave;->measuringModel:Llt/noframe/gpsfarmguide/models/MeasuringModel;

    .line 63
    invoke-direct {p0}, Llt/noframe/gpsfarmguide/views/ActivitySave;->ini()V

    .line 64
    invoke-direct {p0}, Llt/noframe/gpsfarmguide/views/ActivitySave;->fillInfo()V

    .line 66
    new-instance p1, Landroid/os/Handler;

    invoke-direct {p1}, Landroid/os/Handler;-><init>()V

    .line 67
    new-instance v0, Llt/noframe/gpsfarmguide/views/ActivitySave$1;

    invoke-direct {v0, p0}, Llt/noframe/gpsfarmguide/views/ActivitySave$1;-><init>(Llt/noframe/gpsfarmguide/views/ActivitySave;)V

    const-wide/16 v1, 0x1f4

    invoke-virtual {p1, v0, v1, v2}, Landroid/os/Handler;->postDelayed(Ljava/lang/Runnable;J)Z

    return-void
.end method

.method public onCreateOptionsMenu(Landroid/view/Menu;)Z
    .locals 2

    .line 79
    invoke-virtual {p0}, Landroidx/appcompat/app/AppCompatActivity;->getMenuInflater()Landroid/view/MenuInflater;

    move-result-object v0

    const v1, 0x7f0d0003

    invoke-virtual {v0, v1, p1}, Landroid/view/MenuInflater;->inflate(ILandroid/view/Menu;)V

    const/4 p1, 0x1

    return p1
.end method

.method public onOptionsItemSelected(Landroid/view/MenuItem;)Z
    .locals 3

    .line 85
    invoke-interface {p1}, Landroid/view/MenuItem;->getItemId()I

    move-result v0

    const v1, 0x102002c

    const/4 v2, 0x1

    if-eq v0, v1, :cond_2

    const v1, 0x7f09006a

    if-eq v0, v1, :cond_0

    .line 96
    invoke-super {p0, p1}, Landroid/app/Activity;->onOptionsItemSelected(Landroid/view/MenuItem;)Z

    move-result p1

    return p1

    .line 91
    :cond_0
    invoke-direct {p0}, Llt/noframe/gpsfarmguide/views/ActivitySave;->isInputsValid()Z

    move-result p1

    if-eqz p1, :cond_1

    .line 92
    invoke-direct {p0}, Llt/noframe/gpsfarmguide/views/ActivitySave;->saveMeasure()V

    :cond_1
    return v2

    .line 87
    :cond_2
    invoke-virtual {p0}, Landroid/app/Activity;->finish()V

    return v2
.end method
